package com.usian.job;

import com.usian.pojo.Product;
import com.usian.service.ProductService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;

import java.util.List;

/*自动审核*/
@Component
@Log4j2
public class DemoJob {
    @Autowired
    private ProductService productService;

    /**
     * 每天0点执行一次
     * @param param
     * @return
     * @throws Exception
     */
    @XxlJob("demo")
    public ReturnT<String> hello(String param) throws Exception {
        log.info("自媒体文章审核调度任务开始执行....");
        List<Product> releaseIdList = productService.productfindAll();
        List<String> name=productService.findAllNames();
        for(Product product:releaseIdList){
            for (String s:name){
                if(product.getSku()>100||product.getName().equals(s)){
                    if(product.getSku()>100){
                        product.setStatus(4);
                        productService.productUpdate(product);
                    }else {
                        product.setStatus(3);
                        productService.productUpdate(product);
                    }
                }
            }
        }
        log.info("自媒体文章审核调度任务执行结束....");
        return ReturnT.SUCCESS;
    }
}
